package com.suray.basic.wcs.plc.utils;

/**
 * 0:无效  1:拆盘  2:叠盘   3:进整托 4:出整托  5:正常托盘输送
 */
public enum PlcTaskType {
    INVALID(0, "无效"),
    REMOVE_PALLET(1, "拆盘"),
    STACK_PALLET(2, "叠盘"),
    ALL_IN(3, "进整托"),
    ALL_OUT(4, "出整托"),
    NORMAL_TASK(5, "正常托盘输送"),
    ;

    int value;
    String des;
    PlcTaskType(int value, String des) {
        this.value = value;
        this.des = des;
    }

    public int getValue() {
        return value;
    }

    public static PlcTaskType parseValue(int value) {
        for (PlcTaskType taskType : PlcTaskType.values()) {
            if (taskType.value == value) {
                return taskType;
            }
        }

        return INVALID;
    }

    @Override
    public String toString() {
        return des;
    }

    public static PlcTaskType parseTaskNo(int value) {
        return parseValue(value / 10000);
    }

    public int generalTaskNo(int taskNo) {
        return value * 10000 + taskNo;
    }
}
